package com.kai.data;

import java.util.Queue;

import com.kai.prety.BluetoothActivity;

import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;

public class QueueData extends Service{
	
	private Handler handler = new Handler();
	private GetQueueData getQueueData = null;
	
	class GetQueueData implements Runnable {

		private Queue<Data> queue;

		public GetQueueData(Queue<Data> queue) {
			super();
			this.queue = queue;
		}

		@Override
	public void run() {
	
		// TODO Auto-generated method stub
		Queue<Data> datas = queue;
		Data data = datas.poll();
		if(data!=null){
			Intent intent = new Intent();
			intent.putExtra("DATA", data);
			intent.setClass(QueueData.this,BluetoothActivity.class);
			startActivity(intent);
		}
		handler.postDelayed(getQueueData, 10);
	}

	}

	@Override
	public IBinder onBind(Intent arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	@Deprecated
	public void onStart(Intent intent, int startId) {
		// TODO Auto-generated method stub
		super.onStart(intent, startId);
		getQueueData = new GetQueueData((Queue<Data>)intent.getParcelableExtra("QUEUE"));
		handler.postDelayed(getQueueData, 10);
	}
	
	
}
